package services;

import java.util.List;

import javax.mail.MessagingException;
import javax.mail.internet.AddressException;

import business.CompanyCampaign;
import business.PollStatus;
import utils.MailUtils;

public class NotificationsService {
	
	public void sendNotificationStatusChange(String templateFilePath, CompanyCampaign companyCampaign,PollStatus pollStatus)
	{
		UserService userService = new UserService();
		List<String> emails = userService.getEmailsToSendNotifications(companyCampaign.getId());
		
		String mailContent = MailUtils.generateMailContent(templateFilePath, companyCampaign.getCompany()
				.getBusinessName(), companyCampaign.getCompany().getCuit(),
				companyCampaign.getCampaign().getDescription(), companyCampaign
						.getCampaign().getYear(), pollStatus.getStatus());
		
		try {
			MailUtils.sendEmail(emails, "Ha cambiado el estado de una encuesta.", mailContent);
		} catch (AddressException e) {
			// TODO VER COMO MANEJAR!! MENSAJE!!
			e.printStackTrace();
		} catch (MessagingException e) {
			// TODO VER COMO MANEJAR!! MENSAJE!!
			e.printStackTrace();
		}		
	}
}
